package com.boomsecret.netty.websocket;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.SimpleChannelInboundHandler;
import io.netty.handler.codec.http.websocketx.TextWebSocketFrame;

/**
 * @author: wangjinliang
 * @date: 2020/10/27
 */
public class WebSocketServerHandler extends SimpleChannelInboundHandler<TextWebSocketFrame> {

    @Override
    protected void channelRead0(ChannelHandlerContext ctx, TextWebSocketFrame msg) throws Exception {
        String content = "客户端发来信息：" + msg.text();
        System.out.println(content);
        ctx.writeAndFlush(new TextWebSocketFrame(content));
    }
}
